<?php

namespace App\Providers;

use Closure;
use Illuminate\Support\ServiceProvider;
use App\Supports\BatchChunk\BatchChunk;
use Illuminate\Database\Eloquent\Builder;

class MacroServiceProvider extends ServiceProvider
{
	public function boot()
	{
		$this->builderMacro();
	}
	
	protected function builderMacro()
	{
		Builder::macro('chunks', function ($count, Closure $closure, $orderDirection = null, $orderColumn = null) {
			return app(BatchChunk::class)->setBuilder($this)
				->chunks($count, $closure, $orderDirection, $orderColumn);
		});
	}
}
